Silence for Solutions

P1.
#include <stdio.h>
#include <conio.h>
void main()
{
printf("\n Welcome");
getch();
}

P2.
#include <stdio.h>
#include <conio.h>
void main()
{
int a,b,c;
printf("Enter First no.\n");
scanf("%d",&a);
printf("Enter second no.\n");
scanf("%d",&b);
c=a+b;
printf("\n Sum= %d",c);
getch();
}

P3.
#include <stdio.h>
#include <conio.h>
void main()
{
int a,b,c;
printf("Enter First no.\n");
scanf("%d",&a);
printf("Enter second no.\n");
scanf("%d",&b);
c=a-b;

printf("\n Difference= %d",c);
getch();
}

P4.
#include <stdio.h>
#include <conio.h>
void main()
{
int a,b,c;
printf("Enter First no.\n");
scanf("%d",&a);
printf("Enter second no.\n");
scanf("%d",&b);
c=a*b;

printf("\n Product= %d",c);
getch();
}

P5.
#include <stdio.h>
#include <conio.h>
void main()
{
int a,b,c;
printf("Enter First no.\n");
scanf("%d",&a);
printf("Enter second no.\n");
scanf("%d",&b);
c=(int)(a/b);

printf("\n Quotient= %d",c);
getch();
}

P6.
#include <stdio.h>
#include <conio.h>
void main()
{
int a,b,c;
printf("Enter First no.\n");
scanf("%d",&a);
printf("Enter second no.\n");
scanf("%d",&b);
c=a%b;

printf("\n Modulus= %d",c);
getch();
}



P7.
#include <stdio.h>
#include <conio.h>
void main()
{
char x;
printf("Enter your gender\n");
x=getchar();
printf("\n\n Gender = ");
putchar(x);
getch();
}

P8. (Also given under the head "A little more of 'C'")
#include <stdio.h>
#include <conio.h>
void main()
{ char a, int p;
printf("Press 1 to convert from lower to upper OR 2 to convert from upper to lower\n");
scanf("%d",&p);
switch(p)
{case 1: printf("Enter any lowercase character\n");
a=getchar();
if(a<=122&&a>=97)
{a-=32;
putchar(a);}
else
printf("Entered character is not a lowercase character\n");
break;
case 2: printf("Enter any uppercase character\n");
a=getchar();
if(a<=90&&a>=65)
{a+=32;
putchar(a);}
else
printf("Entered character is not an uppercase character\n");
break;
default: printf("Entered choice is wrong\n");
}
getch();
}


2 comments: