Write a C program which asks the user to enter a name of a
person and the program finds the number of that person. The number
is displayed. Otherwise output "Not found". Your program have to
check only given names.
The program declares and initializes a two-dimensional array of
characters that holds pairs of names and numbers. The array can
hold 10 strings, each capable of holding up to 79 characters. Array
elements are following:
"Adam", "585-5622",
"Mark", "505-8446",
"Austin", "955-1055",
"Satish", "444-1490",
"James", "555-8873"
Hint:Use strcmp().
Sample input:
Austin
Sample output:
955-1055
#include<stdio.h>
#include<string.h>
int main()
{
//initialize the two diensional character array
by 10 names and numbers
char
name[10][79]={"Adam","585-5622","Mark","505-8446",
"Austin","955-1055","Satish","444-1490","James","555-8873"};
int i,opt;
char nm[79];
//ask for a name to search
printf("\n Enter the name");
gets(nm);
//loop to scan the array elements
//the step value is i+=2 because at even
position inly the names are occupied
for(i=0;i<10;i+=2)
{
//compare the users entry name
awith the existing data in name[]
if(strcmp(nm,name[i])==0)
{//if found then set opt=1 and
terminate the loop by break;
opt=1;
break;
}
}
//if opt=1 then display the number of that
person
if(opt==1)
printf("\n The number is :
%s",name[i+1]);
else
//print data not fund if opt!=1
printf("\n Not Found");
}
output
Write a C program which asks the user to enter a name of a person and...
Project 1, Program Design 1. Write a C program replace.c that asks the user to enter a three-digit integer and then replace each digit by the sum of that digit plus 6 modulus 10. If the integer entered is less than 100 or greater than 999, output an error message and abort the program. A sample input/output: Enter a three-digit number: 928 Output: 584 2. Write a C program convert.c that displays menus for converting length and calculates the result....
User Profiles Write a program that reads in a series of customer information -- including name, gender, phone, email and password -- from a file and stores the information in an ArrayList of User objects. Once the information has been stored, the program should welcome a user and prompt him or her for an email and password The program should then use a linearSearch method to determine whether the user whose name and password entered match those of any of...
C Programming write two functions, similar to what you see in the sample program. The first will ask the user to enter some information (I have included the type in parentheses) First Name (char[]) Last Name (char[]) Age (int) Height in Inches (double) Weight in Pounds (double) You will use pass-by-reference to modify the values of the arguments passed in from the main(). Remember that arrays require no special notation, as they are passed by reference automatically, but the other...