Concept explainers
Help me fix my c
#include <stdio.h>
#include <stdlib.h>
#define _CRT_SECURE_NO_WARNINGS
void addContact();
void viewContact();
char firstName();
char lastName();
char phoneNumber[10];
int main()
{
int selection;
printf("\n\t---Contact Mangement System--");
printf("\n\t[1] Add New Contact");
printf("\n\t[2] View Contact");
printf("\n\t[3] Help");
printf("\n\t[4] Exit");
printf("\n\tEnter Your Selection");
scanf("%d", selection);
switch (selection)
{
case 1:
addContact();
break;
case 2:
viewContact();
break;
case 3:
exit(1);
break;
default:
printf("Enter Your Selection");
main();
}
}
void addContact();
{
printf("Enter First Name: ");
scanf("%s", firstName);
printf("Enter Last Name: ");
scanf("%s", lastName);
printf("Enter Your Phone Number: ");
scanf("%s", phoneNumber);
if (strlen(phoneNumber) == 10)
{
FILE* fp;
fp = fopne("contacts.txt", "w");
fputs(firstName, fp);
fputs(lastName, fp);
fputs(phoneNumber, fp);
printf("\n\tContact Added");
fclose(fp);
}
main();
}
void viewContact()
{
system("cls");
char rfirstName[20];
char rlastName[20];
char rphoneNumber[20];
FILE* fp;
fp = fopen("contacts.txt", "r");
fgets(rfirstName, 9, fp);
fgets(rlastName, 5, fp);
fgets(rphoneNumber, 11, fp);
printf("\n\t---Contact List---");
printf("\n\tFirst Name: %s", rfirstName);
printf("\n\Last Name: %s", rlastName);
printf("\n\Phone Number: %s", rphoneNumber);
main();
}
Step by stepSolved in 3 steps with 5 images
- Data structure & Alogrithums java program A system of caves is a group of connected undergrounds tunnels. Design an ADT for a cave and cave system. An archaelogist should be able to add a newly discovered cave to a cave system. He/she can enter this system through only one cave and exit the system only through a different cave. Duplicate caves - based on GPS coordinates - are not permitted. Archaelogoist should also be able to list the caves in a given cave system.arrow_forwardIn the C programming language, if all function prototypes are listed at the top of your code, outside and above all functions, you do not need to worry about the order of the function definitions within the code. True Falsearrow_forwardOpengl Help Programming Language: c++ I need help setting coordinate boundries for this program so the shape can't leave the Opengl window. The shape needs to stay visiable.arrow_forward
- class Main { // this function will return the number elements in the given range public static int getCountInRange(int[] array, int lower, int upper) { int count = 0; // to count the numbers // this loop will count the numbers in the range for (int i = 0; i < array.length; i++) { // if element is in the range if (array[i] >= lower && array[i] <= upper) count++; } return count; } public static void main(String[] args) { // array int array[] = {1,2,3,4,5,6,7,8,9,0}; // ower and upper range int lower = 1, upper = 9; // throwing an exception…arrow_forward#ifndef INT_SET_H#define INT_SET_H #include <iostream> class IntSet{public: static const int DEFAULT_CAPACITY = 1; IntSet(int initial_capacity = DEFAULT_CAPACITY); IntSet(const IntSet& src); ~IntSet(); IntSet& operator=(const IntSet& rhs); int size() const; bool isEmpty() const; bool contains(int anInt) const; bool isSubsetOf(const IntSet& otherIntSet) const; void DumpData(std::ostream& out) const; IntSet unionWith(const IntSet& otherIntSet) const; IntSet intersect(const IntSet& otherIntSet) const; IntSet subtract(const IntSet& otherIntSet) const; void reset(); bool add(int anInt); bool remove(int anInt); private: int* data; int capacity; int used; void resize(int new_capacity);}; bool operator==(const IntSet& is1, const IntSet& is2); #endifarrow_forward//client.c#include "csapp.h" int main(int argc, char **argv){ int connfd; rio_t rio; connfd = Open_clientfd(argv[1], argv[2]); Rio_readinitb(&rio, connfd); char buffer[MAXLINE]; printf("Your balance is %s\n", buffer); Close(connfd); exit(0); int choice; float amount; int acc2; char buffer[MAXLINE]; rio_t rio; Rio_readinitb(&rio, connfd); while (1) { printf("\nHello welcome to the Bank Management System\n"); printf("----------------------\n"); printf("1. Check Balance\n"); printf("2. Deposit\n"); printf("3. Withdraw\n"); printf("4. Transfer\n"); printf("5. Quit\n"); printf("Enter your choice: "); Rio_writen(connfd, &choice, sizeof(int)); if (choice == 1) { printf("Your balance is %s\n", buffer); } else if (choice == 2) { printf("Enter amount to deposit: "); Rio_writen(connfd, &amount,…arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education