16. Accept Two Numbers from user and find their sum from "goto" statement.
Answer :
#include<stdio.h>
#include<conio.h>
Void main()
{
int num1, num2, sum, result;
clrscr();
printf("Enter Two Numbers:");
scanf("%d%d",& num1, num2);
printf("\n The Sum of Two Number is:");
go to sum;
printf("\n This Statement is just after the goto Statement\n");
printf("\n *************************");
sum;
result= num1 + num2;
printf("%d", result);
getch();
}
_________________________________________________________________________________
17. The Program that receive a number between 1 to 10 and will display its English counterpart.
Answer :
#include<stdio.h>
#include<conio.h>
Void main()
{
int num;
printf("\n Enter Any Number between 1 to 10:");
scanf("%d", & num);
switch(num)
{
case 1: printf("\n One");
break;
case 2: printf("\n Two");
break;
case 3: printf("\n Three");
break;
case 4: printf("\n Four");
break;
case 5: printf("\n Five");
break;
case 6: printf("\n Six");
break;
case 7: printf("\n Seven");
break;
case 8: printf("\n Eight");
break;
case 9: printf("\n Nine");
break;
case 10: printf("\n Ten");
break;
default: printf("\n Wrong Choice");
}
printf("\n Thank You....");
getch();
}
Answer :
#include<stdio.h>
#include<conio.h>
Void main()
{
int num1, num2, sum, result;
clrscr();
printf("Enter Two Numbers:");
scanf("%d%d",& num1, num2);
printf("\n The Sum of Two Number is:");
go to sum;
printf("\n This Statement is just after the goto Statement\n");
printf("\n *************************");
sum;
result= num1 + num2;
printf("%d", result);
getch();
}
_________________________________________________________________________________
17. The Program that receive a number between 1 to 10 and will display its English counterpart.
Answer :
#include<stdio.h>
#include<conio.h>
Void main()
{
int num;
printf("\n Enter Any Number between 1 to 10:");
scanf("%d", & num);
switch(num)
{
case 1: printf("\n One");
break;
case 2: printf("\n Two");
break;
case 3: printf("\n Three");
break;
case 4: printf("\n Four");
break;
case 5: printf("\n Five");
break;
case 6: printf("\n Six");
break;
case 7: printf("\n Seven");
break;
case 8: printf("\n Eight");
break;
case 9: printf("\n Nine");
break;
case 10: printf("\n Ten");
break;
default: printf("\n Wrong Choice");
}
printf("\n Thank You....");
getch();
}
_________________________________________________________________________________
18. Write a Program to print the sum of first 10 even numbers.
Answer :
#include<stdio.h>
#include<conio.h>
Void main()
{
int i, sum=0;
for(i=1; i<=20; ++i)
{
if(i%2!=0) continue;
sum=sum+i;
printf("\n The Sum of First 10 Even Numbers is %d", sum);
}
getch();
}
_________________________________________________________________________________
19. Write a Program for the sum of numbers as many user wants?
Answer :
#include<stdio.h>
#include<conio.h>
Void main()
{
int num, sum=0;
char ch;
Read:
printf("Enter the Number:");
scanf("%d", & num);
sum= sum+num;
printf("You Want to Enter More Number, Enter Y");
fflush(stdin);
scanf("%c",&ch);
if(ch == 'y' || ch == 'y')
goto read;
printf("The Sum of N Numbers =%d", sum);
getch();
}
_________________________________________________________________________________
20. Accept Two Numbers from user and print their addition and subtraction.
Answer :
#include<stdio.h>
#include<conio.h>
Void main()
{
int a,b,ch;
printf("Enter Two Numbers:");
scanf("%d%d",&a,&b);
printf("\n Press 1 : For Addition");
printf("\n Press 2 : For Substraction");
printf("Enter Your Choice:");
scanf("%d", &ch);
switch(ch)
{
case 1: printf("Addition= %d", a+b);
break;
case 2: printf("Substraction=%d", a-b);
break;
default: printf("Wrong Choice");
}
getch();
}
*********************************************************************************
0 comments:
Post a Comment