Professional Documents
Culture Documents
Ict
Ict
Ict
ABBOTABBAD CAMPUS
PART A
Write a program for a Bank account in which show user name, account
number and use menu driven program which has following options: a) Show
Balance b) Debit Amount c) Credit Amount d) Exit When any
option/operation execute name and account number will be at the top
#include <stdio.h>
#include <string.h>
int main() {
char name[50];
int accountNumber;
scanf("%49s", name);
scanf("%d", &accountNumber);
int choice;
float amount;
while (1) {
printf("\nMenu:\n");
printf("4. Exit\n");
scanf("%d", &choice);
switch (choice) {
case 1:
break;
case 2:
printf("Insufficient balance!\n");
} else {
balance -= amount;
break;
case 3:
scanf("%f", &amount);
balance += amount;
break;
case 4:
return 0;
default:
break;
return 0;
}
OUTPUT:
FLOW CHART
START
"Enter the account
holder's name"
Loop Start
(while (1))
Display Menu
T
(choice == 1) Display Account
Information
F T
"Enter Debit
(choice == 2)
Amount"
F
T "Enter Credit
(choice == 3) Amount"
F
T "Exiting the
(choice == 4) program..."
F
END
QUESTION 1
PART B
A company decides to give bonus to all its employees on ‘Eid. A 5% bonus on
salary is given to the male workers and 10% bonus on salary to the female
workers. Write a program to enter the salary and gender of the employee. If
the salary of the employee is less than 10,000 the employ gets extra 2% bonus
on salary. Calculate the bonus that has to be given to the employee and display
the salary that employee will get.
#include <stdio.h>
int main() {
float salary, bonus;
char gender;
printf("Enter M for Male and F for Female: ");
scanf("%c", &gender);
if (gender == 'M' || gender == 'm') {
printf("Enter Salary: ");
scanf("%f", &salary);
if (salary > 10000) {
bonus = salary * 0.05; // 5% bonus
} else {
bonus = salary * 0.07; // 7% bonus
}
} else if (gender == 'F' || gender == 'f') {
printf("Enter Salary: ");
scanf("%f", &salary);
if (salary > 10000) {
bonus = salary * 0.1; // 10% bonus
} else {
bonus = salary * 0.12; // 12% bonus
}
}
else
printf("\nInvalid input\n");
salary += bonus;
printf("Bonus: %.2f\nSalary: %.2f\n", bonus, salary);
return 0;
}
PROGRAM
OUTPUT:
FLOW CHART:
Start
Input Gender
F T
Gender == 'M' or 'm'?
F
Enter Salary
gender == 'F' || gender
== 'f' T
F T
Salary > 10000?
bonus = bonus =
salary * 0.12 salary * 0.1
END
QUESTION 2
Part A
#include <stdio.h>
int main() {
int number, sum = 0;
printf("Enter a 5-digit number: ");
scanf("%d", &number);
if (number < 10000 || number > 99999) {
printf("Invalid input! Please enter a 5-digit number.\n");
return 1;
}
while (number > 0) {
sum += number % 10;
number /= 10;
}
printf("The sum of the digits is: %d\n", sum);
return 0;
}
PROGRAM:
OUTPUT:
PART B
#include <stdio.h>
int main() {
float exam1, exam2, sports, activity1, activity2, activity3;
float total_exam, total_activities, total_weighted_score;
return 0;
}
Program:
OUTPUT:
Part C
LAB TASK 9
Question No: 1
#include<stdio.h>
int main(){
int a = 0;
if(a=10)
printf("%d",a);
return 0;
}
Program:
OUTPUT:
CORRECT THE PROGRAM:
#include<stdio.h>
int main(){
int a = 0;
if(a==10)
printf("%d",a);
return 0;
}
PROGRAM
OUTPUT:
Question No 2:
#include <stdio.h>
int main()
{
int a = 2 , b=3 , c=4 ;
if(b==2){
a=10;
}
else
c=10;
printf("\na = %d\nb = %d\nc = %d",a,b,c);
return 0;
}
PROGRAM:
OUTPUT:
Question NO 3:
#include <stdio.h>
int main()
{
int a = 2 , b=3 , c=4 ;
if(a&&b){
c=10;
}
else
c=20;
printf("\na = %d\nb = %d\nc = %d",a,b,c);
return 0;
}
PROGRAM:
OUTPUT:
Question No 4:
#include <stdio.h>
int main()
{
int a = 2 , b=3 , c=4 ;
if(a||b||c){
c=10;
}
else
c=20;
printf("\na = %d\nb = %d\nc = %d",a,b,c);
return 0;
}
OUTPUT:
Question No 5:
#include <stdio.h>
int main()
{
int a = 2 , b=3 , c=4 ;
if(a)
if(b)
c=10;
else
c=20;
printf("\na = %d\nb = %d\nc = %d",a,b,c);
return 0;
}
PROGRAM:
OUTPUT:
Question No 6:
#include <stdio.h>
int main()
{
int a = 2 , b=3 , c=4 ;
if(a == 0 || b >= c && c> 0)
if(a && b)
c=10;
else
c=20;
printf("\na = %d\nb = %d\nc = %d",a,b,c);
return 0;
}
PROGRAM:
OUTPUT:
Question No 7:
#include <stdio.h
int main()
{
int a = 2 , b=3 , c=4 ;
if(a = b)
c++;
printf("\na = %d\nb = %d\nc = %d",a,b,c);
return 0;
}
PROGRAM:
OUTTPUT:
Question NO 8:
#include <stdio.h>
int main()
{
int a = 2 , b=3 , c=4 ;
if(a = b < c){
c++;
a--;
}
++b;
printf("\na = %d\nb = %d\nc = %d",a,b,c);
return 0;
}
OUTPUT:
Question No 9:
#include <stdio.h>
int main()
{
int i = 3;
switch(i){
case 0:
printf("\nCustomers are dicey");
case 1+0:
printf("\nMarkets are pricey");
case 4/2:
printf("\nlnverstors are moody");
case 8%5:
printf("\nAt least employees are good");
}
return 0;
}
PROGRAM:
OUTPUT:
Question No 10:
#include <stdio.h>
int main()
{
int k ;
float j = 2.0;
switch(k = j+1){
case 3:
printf("\nTrapped");
break;
default:
printf("\nCaught!");
}
return 0;
}
OUTPUT:
Question No 11:
#include <stdio.h>
int main()
{
int ch = 'a' + 'b';
switch(ch){
case 'a':
case 'b':
printf("\nYou entered b");
case 'A':
printf("\na as in ashar");
case 'b'+'a':
printf("\nYou entered a and b");
}
return 0;
}
OUTPUT:
Question No 12:
#include <stdio.h>
int main()
{
int i = 1;
switch(i-2){
case -1:
printf("\nFeeding fish");
case 0:
printf("\nWeeding grass");
case 1:
printf("\nmending roof");
default:
printf("\njust to survive");
}
return 0;
}
OUTPUT:
Question No 13:
#include <stdio.h>
int main()
{
int temp ;
scanf("%d",&temp);
switch(temp){
case (temp <= 20):
printf("\nOooooooh ! Damn cool");
case (temp > 20 && temp <= 30):
printf("\nRain rain here again");
case (temp > 30 && temp <= 40):
printf("\nWish I am on Everest");
default:
printf("\nGood old nagpur weather");
}
return 0;
}
OUTPUT:
Correct the program:
#include <stdio.h>
int main()
{
int temp ;
scanf("%d",&temp);
switch(temp){
case 1:
printf("\nOooooooh ! Damn cool");
break;
case 2:
printf("\nRain rain here again");
break;
case 3:
printf("\nWish I am on Everest");
break;
default:
printf("\nGood old nagpur weather");
}
return 0;
}
OUTPUT:
LAB TASK 8
Question No 1:
#include <stdio.h>
int main()
{
int k , num = 30;
k = (num>5?(num<=10?100:200):500);
printf("num = %d",num);
return 0;
}
PROGRAM:
OUTPUT:
Question No 2:
#include <stdio.h>
int main()
{
int a = 15 , b = 10 , c = -3 ,res;
res = a>b&&a>c;
printf("res = %d",res);
return 0;
}
OUTPUT:
Question No 3:
#include <stdio.h>
int main()
{
int a = 5, _c = -3 ;
_c = a+3*a++;
printf("_c = %d\t a = %d",_c,a);
return 0;
}
OUTPUT:
Question No 4:
#include <stdio.h>
int main()
{
int x = 100 , 30 ,50;
printf("x = %d",x);
x = (100,30,50);
printf("x = %d",x);
return 0;
}
OUTPUT:
Question No 5:
#include <stdio.h>
int main()
{
int x = 3 , y = 5 , z = 7;
int a , b;
a = x * 2 + y / 5 - z * y;
b = ++x * (y-3) / 2 - z++ * y;
printf("\n a = %d",a);
printf("\n b = %d",b);
return 0;
}
OUTPUT:
Question No 6:
#include <stdio.h>
int main()
{
int a = 4 , b= 1 , c = -3 , res;
res = a > b && a < c ;
printf("\n %d ",res);
res = a == c || a < b ;
printf("\n %d ",res);
res = b > 10 || b && c < 0 || a > 0;
printf("\n %d ",res);
res = (a/2.0 == 0.0 && b/2.0 !=0.0)||c<0.0;
printf("\n %d ",res);
return 0;
}
OUTPUT:
Question No 7:
#include <stdio.h>
int main()
{
int a = 10;
printf("\na = %d",5+a++);
printf("\na = %d",5+ ++a);
return 0;
}
OUTPUT:
Question No 8:
#include <stdio.h>
int main()
{
int a = 15 , b=-10 , _=3;
_=a-b;
printf("\n_ = %d",++_);
return 0;
}
OUTPUT:
Question No 9:
#include <stdio.h>
int main()
{
const char var = 'A';
++var;
printf("\nvar = %c",var);
return 0;
}
OUTPUT:
CORRECT THE ERROR:
We can not change the value of constant
#include <stdio.h>
int main()
{
char var = 'A';
++var;
printf("\nvar = %c",var);
return 0;
}
OUTPUT:
Question No 10:
#include <stdio.h>
int main()
{
char var = 'B';
var+=2;
var++;
printf("\nvar = %c , var = %d",var , var);
return 0;
}
OUTPUT:
Question No 11:
#include <stdio.h>
int main()
{
int a = 3;
int b = ++a;
printf("value of b = %d",b);
a = b++;
b = a++;
printf("%d %d",b,a);
return 0;
}
OUTPUT:
Question No 12:
#include <stdio.h>
int main()
{
int a,b=3;
char c = 'A';
a = b+c;
int b = ++a;
printf("value of a = %d",a);
return 0;
}
OUTPUT:
#include <stdio.h>
int main()
{
int a,b=3;
char c = 'A';
a = b+c;
int B = ++a;
printf("value of a = %d",a);
return 0;
}
OUTPUT: