Sie sind auf Seite 1von 36

INTRODUCTION TO PROGRAMMING [RA18]

COURSE PROJECT : 2019-20

Team Members:

19K41A0558-SHANIGARAM SAI CHAITHANYA

19K41A0439-GUDIPATI SADHVIK REDDY

19K41A0553-PASHIKANTI SAKETH

19K41A0459-THEDLA ANAND

Under the Guidance of

Mr. P PRAMOD KUMAR


M.Tech.(Ph.D)

Senior Assistant Professor

Department Computer Science and Engineering


PROBLEM STATEMENT:
Develop a Menu-Driven C application to select a specific choice from

multiple options for each topic of Introduction to Programming

repetitively and get its respective output onto the screen.

DESCRIPTION:
(Describe about the chosen scenario within 150 to 200 words)

CONCEPTS USED TO DEVELOP THIS APPLICATION:

Operators

Expression Evaluation and Type Conversion

Conditional Statements (if, switch and nested statements)

Looping Statements (for, while , do while and nested loops)

Unconditional Jump Statements(goto, break and continue)

Arrays (1-D Array and 2-D Array)

Strings (Strings, Table of Strings) and string handling functions

#include<stdio.h>
#include<math.h>

#include<conio.h>

#include<string.h>

#include<stdlib.h>

int main()

int
digit,i=1,n,sum=0,age,rem,res=0,a,b,c,dc=0,amt,p,q,r,s,j,total,num,year,count=0,l
eapyear,sel,nonleapyear,f,f1=-
1,f2=1,fact=1,ipmarks,updatedipmarks,marks=12,k=1,rev=0,temp,temp1,gdays,m
onths,rdays,len,flag,g[i][j],t[i][j],h[i][j],x[3][3],y[3][3],z[3][3],size,a1[5],lnum[5][5],l
nsf,arr[5][5],rsum=0,csum=0,gtotal=0,rows,coef=1,length=0,space;

flag=0;

char
indian,ch,proceed,sh,code,str[100],s1[100],s2[100],s3[120],str4[20]="beginners
book",Str1[50],Str2[50],string[50],string1[30];

float
attendence,w1,w2,n1,n2,avg,balance,bonus,ph1,ph2,m1,m2,m3,percentage,per,c
redits;

int min,max;

long odd_sum=0,even_sum=0;

do

printf("\n press1.to get sum digit");

printf("\n press2.to get sum of n natural numbers");


printf("\n press3.to print given number in words");

printf("\n press4.to check wheather the person is eligible to cast vote


or not");

printf("\n press5.to print numbers in ascending order by using while


constrol state");

printf("\n press6.to print big c");

printf("\n press7.to print big f");

printf("\n press8.to get area of geometry");

printf("\n press9.to check wheather a given number is armstrong


number or not");

printf("\n press10.to know the use of assosiativity rule");

printf("\n press11.to check wheather given person is eligle to write


exam or not");

printf("\n press12.to get result of given equation by two inputs");

printf("\n press13.to check wheather a given number is even or


odd");

printf("\n press14.to checks marks through distiction");

printf("\n press15.to get sum of even and odd numbers");

printf("\n press16.to check wheather given year is leap or not");

printf("\n press17.to get fabonacii number of a given number");

printf("\n press18.to check wheather given number is perfect or


not");

printf("\n press19.to know credits using attendence");


printf("\n press20.to get greatest between three numbers using if
else");

printf("\n press21.to know greatest number between given two


numbers using if else");

printf("\n press22.to get factorial of a given number");

printf("\n press23.to wheather given number is prime or not");

printf("\n press24.to know the use of backward jump");

printf("\n press25.to know the use of forward jump");

printf("\n press26.to know no of months and no of remainings days


from given days");

printf("\n press27.to know the largest height of two persons");

printf("\n press28.to know the use of bitwise operators");

printf("\n press29.to get updated ip marks");

printf("\n press30.to get colours by typing its starting letter");

printf("\n press31.to know the use of assignment operator");

printf("\n press32.to know use of increment and decrement


operator");

printf("\n press33.to print numbers in line");

printf("\n press34.to check wheather a given number is palindrom or


not");

printf("\n press35.to know how nested if else works");

printf("\n press36.to know the use of simple if");

printf("\n press37.to get table of a given number");


printf("\n press38.to get multiple of a matrix");

printf("\n press39.to pick up the large number from any 5row by 5


column matrix");

printf("\n press40.to get sum and grand total of array");

printf("\n press41.to find length of a string");

printf("\n press42.to copy one string to another string");

printf("\n press43.to to concate two strings");

printf("\n press44.to commpare to strings");

printf("\n press45.to determine if the given string is a palindrom or


not");

printf("\n press46.to demonstrate all strings handling functions");

printf("\n press47.to add two matrixs");

printf("\n\n make your main menu selection");

scanf("%d",&sel);

printf("\n\n\n###submenu####");

switch(sel)

case 1:printf("\n Enter a num:");

scanf("%d",&num);

while(num>0)

rem=num%10;
sum+=rem;

num/=10;

printf("\n sum of digits of given num=%d",sum);

break;

case 2:printf("\n Enter value of n");

scanf("%d",&n);

while(i<=n)

sum+=i;

i++;

printf("\n sum of first %d natural numbers is %d",n,sum);

break;

case 3:printf("\n enter a digit(1-3)");

scanf("%d",&digit);

switch(digit)

case 1:printf("\n one");

break;

case 2:printf("\n two");

break;
case 3:printf("\n three");

break;

default:printf("\n invalid digit");

break;

case 4:printf("\n enter age of person");

scanf(" %d",& age);

printf("\n enter resident status (y in case of indian otherwise n)of


person");

scanf(" %c",& indian);

if("(age>=18)&&(indian==y)")

printf("\n eligible to cast a vote");

else

printf("\n not eligible");

break;

case 5:printf("\n Enter value of n");

scanf("%d",&n);

while(i<=n)

printf("\n %d",i++);

break;
case 6:printf("\n######");

printf("\n## ##");

printf("\n#");

printf("\n#");

printf("\n#");

printf("\n#");

printf("\n#");

printf("\n## ##");

printf("\n######");

break;

case 7:printf("\n######");

printf("\n#");

printf("\n#");

printf("\n#####");

printf("\n#");

printf("\n#");

printf("\n#");

break;

case 8:printf("\n enter geometric shape r for rectangle,s for square,t for
triangle");

scanf("%c",&sh);

switch (sh)
{

case 'r':

float l,b;

printf("\n enterl,b");

scanf("%f%f",&l,&b);

printf("\n area=%f",l*b);

break;

case 's':

float a;

printf("\n enter a");

scanf("%f",&a);

printf("\n area=%f",a*a);

break;

case 't':

float b,h;

printf("\n enter b,h");

scanf("%f%f",&b,&h);
printf("\n area=%f",0.5*b*h);

break;

default:printf("\n invalid entry");

break;

case 9:printf("\n Enter a num");

scanf("%d",&num);

temp=temp1=num;

while(num>0)

rem=num%10;

dc++;

num/=10;

while(temp>0)

rem=temp%10;

sum+=pow(rem,dc);

temp/=10;

if(sum==temp1)
printf("\n Given num is an Armstrong num");

else

printf("\n Given numis not an Armstrong num");

case 10:printf("\n res1=%d",a-b+c);

printf("\n res2=%d",a+b-c);

printf("\n res3=%d",a*b/c%2);

printf("\n res4=%d",a/b*c%2);

break;

case 11:printf("\n enter attendence percentage");

scanf(" %f",&percentage);

if ( percentage>75)

printf("\n you are eligible to attened exam");

else

printf("\n you are not eligible to attened exam");

break;

case 12:printf("\n enter a,b values");

scanf("%d%d",&a,&b);

res=(a+6)>b?a-2:b*2;

printf("\n result=%d",res);

break;

case 13:printf("\n enter a number");

scanf("%d",&num);
if(num%2==0)

printf("\n even");

else

printf("\n odd");

break;

case 14:printf("\n enter 3 subjects marks");

scanf("%f%f%f",&m1,&m2,&m3);

per=((m1+m2+m3)/300)*100;

if(per>=70)

printf("\n distinction");

else if(per>=60)

printf("\n first class");

else if(per>=50)

printf("\n second class");

else if(per>=40)

printf("\n third class");

else

printf("\n fail");

break;

case 15:printf("\n enter the minimum range");

scanf("%d",&min);

printf("\n enter the maximum range");


scanf("%d",&max);

for(num=min;num<=max;num++)

if (num%2!=0)

odd_sum=odd_sum+num;

else

even_sum=even_sum+num;

printf("\n sumof even num in given range is:%d",even_sum);

printf("\n sum of odd num in given range is:%d",odd_sum);

break;

case 16:printf("\n enter a year");

scanf("%d",&year);

if(year%4==0)

printf("\n leapyear");

else

printf("\n nonleapyear");

break;

case 17:printf("\n Enter the nth term:");

scanf("%d",&n);

printf("\n The fibonacci series is:");

do
{

f=f1+f2;

f1=f2;

f2=f;

printf("\t%d",f);

n--;

while(n>=f-3);

break;

case 18:printf("\n Enter a num:");

scanf("%d",&n);

while(i<n)

if(n%i==0)

sum=sum+i;

i++;

if (sum==n)

printf("\n %d is a perfect num",n);

else

printf("\n %d is not a perfect num",n);

break;
case 19:

printf("\n enter attendence");

scanf("%f",&attendence);

printf("\n enter number of credits");

scanf("%f",&credits);

if((attendence>=75)&&(credits>=19))

printf("\n you are promoted");

else

printf("\n you are not promoted");

break;

case 20:printf("\n enter 3 values");

scanf("%d%d%d",&a,&b,&c);

(a>b)?(a>c)?printf("a"):printf("c"):(b>c)?printf("b"):printf("c");

break;

case 21:printf("\n enter two values");

scanf("%d%d",&a,&b);

(a>b)?printf("a>b"):printf("b>a");

break;

case 22:printf("\n enter value of n");

scanf("%d",&n);

for(n;n>=1;n--)

fact=fact*n;
printf("\n factorial of given num is %d",fact);

break;

case 23:printf("\n Enter a num");

scanf("%d",&num);

while(i<=num/2)

if(num%i==0)

count++;

break;

i++;

if(count==0&&num!=1)

printf("\n %d is a prime num",num);

else

printf("\n %d is not a prime num", num);

break;

case 24:printf("\n Alphabets in english");

printf("\n A");

d:

printf("\n B");
goto d;

printf("\n C");

printf("\n D");

break;

case 25:printf("\n Alphabets in english");

printf("\n A");

goto s;

printf("\n B");

s:

printf("\n C");

printf("\n D");

break;

case 26:printf("\n enter no.of days");

scanf("%i",&gdays);

months=gdays/30;

rdays=gdays%30;

printf("\n%d months&%drdays",months,rdays);

break;

case 27:printf("\n enter heights of two persons");

scanf(" %f %f",&ph1,&ph2);

printf("\n (ph1>=ph2)&&(ph2!=0)=%d",(ph1>=ph2)&&(ph2!=0));

printf("\n (ph1>=ph2)||(ph2!=0)=%d",(ph1>=ph2)||(ph2!=0));
printf("\n !(ph1>=ph2)&&(ph2!=0)=%d",!((ph1>=ph2)&&(ph2!=0)));

break;

case 28:printf("\n enter a,b values");

scanf("%d%d",&a,&b);

printf("\n a&b=%d",a&b);

printf("\n a|b=%d",a|b);

printf("\n a^b=%d",a^b);

printf("\n a<<b=%d",a<<5);

printf("\n a>>b=%d",a>>3);

break;

case 29:printf("\n enter ip marks");

scanf("%d",&ipmarks);

updatedipmarks=ipmarks+2;

printf("\n updatedipmarks=%d",updatedipmarks);

break;

case 30:printf("\n enter a code (rorR for red,gorG for green,borB


for blue");

scanf("%c",&code);

switch (code)

case 'r':

case 'R':printf("\n RED");


break;

case 'G':

case 'g':printf("\n GREEN");

break;

case 'b':

case 'B':printf("\n BLUE");

break;

default:printf("\n invalid code");

break;

case 31:printf("\n enter values of p,q,r,s");

scanf("%d%d%d%d",&p,&q,&r,&s);

if

((r>0)&&(s>0)&&(p%2==0)&&(q>r)&&(s>p)&&(r+s)>(p+q))

printf("\n correct vlaues");

else

printf("\n wrong values");

break;

case 32:marks++;

printf("\n marks=%d",marks);

break;

case 33:printf("\n enter a num");


scanf("%d",&n);

for(i=1;i<=n;i++)

for(j=1;j<=3;j++)

printf("\t %d",k++);

printf("\n");

break;

case 34:printf("\n Enter a num");

temp=num;

while(num>0)

rem=num%10;

rev=rem+(rev*10);

num=num/10;

if(rev==temp)

printf("\n The given num is a palindrome");

}
else

printf("\n The given num is not a palindrome");

break;

case 35:printf("\n enter 3 values");

scanf("%d%d%d",&a,&b,&c);

if(a>b)

if(a>c)

printf("\n %d is greatest among 3",a);

else

printf("\n %d is greatest among 3",c);

else

if (b>c)

{
printf("\n %d is greatest among 3",b);

else

printf("\n %d is greatest among 3",c);

break;

case 36:printf("\n did you attened my last class,if yes


press y or Y if no press n or N");

scanf("%c",&ch);

if (ch=='y'||ch=='Y')

printf(" \n answer my question");

printf("\n next student answer my question");

break;

case 37:printf("\n Enter a number for which you want to get table");

scanf("%d",&num);

for(i=1;i<=10;i++)

printf("\n %d * %d = %d",num,i,num*i) ;
}

break;

case 38:printf("Enter the elements of 3*3 matrix a \n");

for(i = 0; i < 3; i++)

for(j = 0; j < 3; j++)

scanf("%d", &x[i][j]);

printf("Enter the elements of 3*3 matrix b \n");

for(i = 0; i < 3; i++)

for(j = 0; j < 3; j++)

scanf("%d", &y[i][j]);

for(i = 0; i < 3; i++)

for(j = 0; j < 3; j++)

{
z[i][j] = 0;

for(k = 0; k < 3; k++)

z[i][j] = z[i][j] + (x[i][k] * y[k][j]);

printf("The resultant 3*3 matrix c is \n");

for(i = 0; i < 3; i++)

for(j = 0; j < 3; j++)

printf("%d\t", z[i][j]);

printf("\n");

getch();

break;

case 39:for (i = 0; i <= 4; i++)

printf("\n");

for (j = 0; j <= 4; j++)


{

printf("Enter the [%d][%d] : ",i,j);

scanf("%d", &lnum[i][j]);

for (i = 0; i <= 4; i++)

printf("\n");

for (j = 0; j <= 4; j++)

if (lnum[i][j]>lnum[i][j - 1])

lnsf = lnum[i][j];

lnum[i][j] = lnsf;

printf("\nThe largest number is : %d", lnsf);

getch();

break;

case 40:for (i = 0; i <= 4; i++)

printf("\n");

for (j = 0; j <= 4; j++)


{

printf("Enter the [%d][%d] : ",i,j);

scanf("%d", &arr[i][j]);

for (i = 0; i <= 4; i++)

rsum=0;

for (j = 0; j <= 4; j++)

rsum+=arr[i][j];

gtotal+=rsum;

printf("\nrow%d sum:%d",i,rsum);

for (j = 0; j <= 4; j++)

csum=0;

for (i = 0; i <= 4; i++)

csum+=arr[j][i];

}
gtotal+=csum;

printf("\ncol%d sum:%d",j,csum);

printf("\n Grand total: %d",gtotal);

break;

case 41:printf("Enter a string \n");

scanf("%s",string);

scanf("%s",string1);

//gets(string);

/* keep going through each character of the string till its end */

for (i = 0; string[i] != '\0'; i++)

length++;

printf("The length of a string is the number of characters in it \n");

printf("So, the length of %s = %d\n", string, length);

break;

case 42:printf("Enter string s1: ");

scanf("%s",s1);

//gets(s1);

for(i = 0; s1[i] != '\0'; ++i)

{
s2[i] = s1[i];

s2[i] = '\0';

//printf("String s2: %s", s2);

puts(s2);

return 0;

break;

case 43:printf("Enter first string: ");

gets(s1);

printf("Enter second string: ");

gets(s2);

// calculate the length of string s1

// and store it in i

for(i = 0; s1[i] != '\0'; ++i);

for(j = 0; s2[j] != '\0'; ++j, ++i)

s1[i] = s2[j];

s1[i] = '\0';

printf("After concatenation: %s", s1);

return 0;

break;
case 44:printf("\n Please Enter the First String : ");

gets(Str1);

printf("\n Please Enter the Second String : ");

gets(Str2);

for(i = 0; Str1[i] == Str2[i] && Str1[i] == '\0'; i++);

if(Str1[i] < Str2[i])

printf("\n str1 is Less than str2");

else if(Str1[i] > Str2[i])

printf("\n str2 is Less than str1");

else

printf("\n str1 is Equal to str2");

return 0;

break;

case 45:printf("\n Please Enter any String : ");

gets(str);

len = strlen(str);
for(i = 0; i < len; i++)

if(str[i] != str[len - i - 1])

flag = 1;

break;

if(flag == 0)

printf("\n %s is a Palindrome String", str);

else

printf("\n %s is Not a Palindrome String", str);

return 0;

break;

case 46:printf("Length of string str1: %d", strlen(Str1));

return 0;

break;

case 47:printf("Enter the elements of 3*3 matrix a \n");


for(i = 0; i < 3; i++)

for(j = 0; j < 3; j++)

scanf("%d", &g[i][j]);

printf("Enter the elements of 3*3 matrix b \n");

for(i = 0; i < 3; i++)

for(j = 0; j < 3; j++)

scanf("%d", &t[i][j]);

for(i = 0; i < 3; i++)

for(j = 0; j < 3; j++)

h[i][j] == g[i][j] + t[i][j];

}
printf("The resultant 3*3 matrix c is \n");

for(i = 0; i < 3; i++)

for(j = 0; j < 3; j++)

printf("%d\t", h[i][j]);

printf("\n");

getch();

printf("\n\n do you want to excute another program,to


proceed enter y||Y...otherwise press any other key\n");

scanf("%d",&proceed);

}while(proceed=='y'||proceed=='Y');

printf("\n\n thank you for using my application");

RESULT:
press1.to get sum digit
press2.to get sum of n natural numbers
press3.to print given number in words
press4.to check wheather the person is eligible to cast vote or not
press5.to print numbers in ascending order by using while constrol state
press6.to print big c
press7.to print big f
press8.to get area of geometry
press9.to check wheather a given number is armstrong number or not
press10.to know the use of assosiativity rule
press11.to check wheather given person is eligle to write exam or not
press12.to get result of given equation by two inputs
press13.to check wheather a given number is even or odd
press14.to checks marks through distiction
press15.to get sum of even and odd numbers
press16.to check wheather given year is leap or not
press17.to get fabonacii number of a given number
press18.to check wheather given number is perfect or not
press19.to know credits using attendence
press20.to get greatest between three numbers using if else
press21.to know greatest number between given two numbers using if else
press22.to get factorial of a given number
press23.to wheather given number is prime or not
press24.to know the use of backward jump
press25.to know the use of forward jump
press26.to know no of months and no of remainings days from given days
press27.to know the largest height of two persons
press28.to know the use of bitwise operators
press29.to get updated ip marks
press30.to get colours by typing its starting letter
press31.to know the use of assignment operator
press32.to know use of increment and decrement operator
press33.to print numbers in line
press34.to check wheather a given number is palindrom or not
press35.to know how nested if else works
press36.to know the use of simple if
press37.to get table of a given number
press38.to get multiple of a matrix
press39.to pick up the large number from any 5row by 5 column matrix
press40.to get sum and grand total of array
press41.to find length of a string
press42.to copy one string to another string
press43.to to concate two strings
press44.to commpare to strings
press45.to determine if the given string is a palindrom or not
press46.to demonstrate all strings handling functions
press47.to add two matrixs
make your main menu selection 1

###submenu####
Enter a num:321
sum of digits of given num=6

do you want to excute another program,to proceed enter y||Y...otherwise press any
other key y

press1.to get sum digit


press2.to get sum of n natural numbers
press3.to print given number in words
press4.to check wheather the person is eligible to cast vote or not
press5.to print numbers in ascending order by using while constrol state
press6.to print big c
press7.to print big f
press8.to get area of geometry
press9.to check wheather a given number is armstrong number or not
press10.to know the use of assosiativity rule
press11.to check wheather given person is eligle to write exam or not
press12.to get result of given equation by two inputs
press13.to check wheather a given number is even or odd
press14.to checks marks through distiction
press15.to get sum of even and odd numbers
press16.to check wheather given year is leap or not
press17.to get fabonacii number of a given number
press18.to check wheather given number is perfect or not
press19.to know credits using attendence
press20.to get greatest between three numbers using if else
press21.to know greatest number between given two numbers using if else
press22.to get factorial of a given number
press23.to wheather given number is prime or not
press24.to know the use of backward jump
press25.to know the use of forward jump
press26.to know no of months and no of remainings days from given days
press27.to know the largest height of two persons
press28.to know the use of bitwise operators
press29.to get updated ip marks
press30.to get colours by typing its starting letter
press31.to know the use of assignment operator
press32.to know use of increment and decrement operator
press33.to print numbers in line
press34.to check wheather a given number is palindrom or not
press35.to know how nested if else works
press36.to know the use of simple if
press37.to get table of a given number
press38.to get multiple of a matrix
press39.to pick up the large number from any 5row by 5 column matrix
press40.to get sum and grand total of array
press41.to find length of a string
press42.to copy one string to another string
press43.to to concate two strings
press44.to commpare to strings
press45.to determine if the given string is a palindrom or not
press46.to demonstrate all strings handling functions
press47.to add two matrixs

make your main menu selection 2

###submenu####
Enter value of n 12
sum of first 12 natural numbers is 84

do you want to excute another program,to proceed enter y||Y...otherwise press any
other key n

thank you for using our application

Das könnte Ihnen auch gefallen