0% found this document useful (0 votes)
36 views12 pages

Q - 1 Write A C Program For Finding SI of The Given Amount and Rate of Interest

The document contains 5 questions and C program code snippets to solve each question. Question 1 asks to write a program to calculate simple interest given principal, rate of interest, and time. Question 2 asks to subtract two numbers without using subtraction operator. Question 3 asks to swap two numbers using arithmetic operators and bitwise operators. Question 4 checks if a character is a digit, uppercase letter, or lowercase letter. Question 5 checks if a given year is a leap year. Each code snippet implements the logic to solve the corresponding question and includes the author's name at the bottom.

Uploaded by

Nimish Bansal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views12 pages

Q - 1 Write A C Program For Finding SI of The Given Amount and Rate of Interest

The document contains 5 questions and C program code snippets to solve each question. Question 1 asks to write a program to calculate simple interest given principal, rate of interest, and time. Question 2 asks to subtract two numbers without using subtraction operator. Question 3 asks to swap two numbers using arithmetic operators and bitwise operators. Question 4 checks if a character is a digit, uppercase letter, or lowercase letter. Question 5 checks if a given year is a leap year. Each code snippet implements the logic to solve the corresponding question and includes the author's name at the bottom.

Uploaded by

Nimish Bansal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 12

Q 1 Write a C program for finding SI of the given

amount and rate of interest.

#include<stdio.h>
#include<conio.h>
main()
{
float p,r,t,si,total;
clrscr();
printf("Enter the principal ");
scanf("%f",&p);
printf("Enter the rate of interest ");
scanf("%f",&r);
printf("Enter the time in years ");
scanf("%f",&t);
printf("\n");
si=(p*r*t)/(100);
//ok
total=p+si;
printf("Your simple interest is %f\n",si);
printf("Your total amount becomes %f ",total);
gotoxy(1,10);printf("--*-*-*-*-*--\nNimish
Bansal\n02816401516");
getch();
}

Q 2. . Write a C program to subtract two


numbers without using subtraction

#include<stdio.h>
#include<conio.h>
main()
{
int a,b,i,ans;
clrscr();
printf("Enter the 1st number
");
scanf("%d",&a);
printf("Enter the second no
- ");
scanf("%d",&b);
ans=a+((~b)+1);
printf("
_____\n");
printf("After subtraction ans is
%d
\n",ans);
printf("
_____");
gotoxy(1,10);printf("--*-*-*-*-*--\nNimish
Bansal\n02816401516");
getch();
}

Q 3 (A) Write a C program to swap 2 numbers


using Arithmetic operator

#include<stdio.h>
#include<conio.h>
main()
{
int a,b;
clrscr();
printf("Enter the first no ");
scanf("%d",&a);
printf("Enter the second no ");
scanf("%d",&b);
printf("\n");
a=a+b;
b=a-b;
a=a-b;
printf("After swapping the 1st no becomes
%d\n",a);
printf("After swapping the 2nd no becomes
%d ",b);
gotoxy(1,10);printf("--*-*-*-*-*--\nNimish
Bansal\n02816401516");
getch();
}

Q 3(B) Write a C program to swap 2 numbers


using bitwise operator

#include<stdio.h>

#include<conio.h>
main()
{
int a,b,c;
clrscr();
printf("Enter the first no ");
scanf("%d",&a);
printf("Enter the second no ");
scanf("%d",&b);
printf("\n");
a=a^b;
b=a^b;

a=a^b;
printf("After swapping the 1st no becomes
%d\n",a);
printf("After swapping the 2nd no becomes
%d ",b);
gotoxy(1,10);printf("--*-*-*-*-*--\nNimish
Bansal\n02816401516");
getch();
}

Q 4 . Write a C program to check whether the


given character is a digit or a character in
lowercase or uppercase alphabet

#include<stdio.h>
#include<conio.h>
main()
{
char a;
clrscr();
printf("Enter the char. to check if it is digit,
uppercase or lowercase alphabet \n\n");
scanf("%c",&a);
printf("\n");
if(a>='0'&&a<='9')

printf("Its a digit");
else if(a>='a'&&a<='z')
printf("It is lower case alphabet");
else if(a>='A'&&a<='Z')
printf("It is uppercase alphabet");
else
printf("It is neither a digit nor an aphabet,its a
special character");
gotoxy(1,10);printf("--*-*-*-*-*--\nNimish
Bansal\n02816401516");
getch();
}

Q.- 5. Write a C program to check whether the


year is a leap year or not.

#include<stdio.h>
#include<stdlib.h>
void main()
{
int n;
int x;
clrscr();
printf("Please enter any year of your
choice: ");
scanf("%d",&n);
if((n%100)==0)
{if((n%400) ==0)
printf("\nTHe given year is a leap year");
else

printf("\nThe given year is not a leap


year");
}
else if ((n%4)==0)
{printf("\nIt is a leap year");
}
else
printf("\nThe given year is not a leap
year");
gotoxy(1,10);printf("--*-*-*-*-*--\nNimish
Bansal\n02816401516");
getch();
}

You might also like