BSC.
IT SEMESTER -1
STUDENT ID :- 24BSIT094
CA-413 INTODUCTION OF PROGRAMING
PRACTICAL ASSSINGMENT – 4
WORKING WITH CHARACTERS & STRINGS
1.WRITE A PROGRAM TO PRINT CHARACTER ENTER BY
PROGRAMER.
CODE:-
#include<stdio.h>
int main()
{
char x='$';
printf("The Character= %c",x);
}
OUTPUT:-
2.WRITE A PROGRAM TO PRINT CHARACTER ENTERED BY THE
USER.
CODE:-
#include<stdio.h>
int main()
{
char Z;
printf(“Enter character=”);
scanf(“%c”,&Z);
printf(“The Character you entered is %c”,Z);
OUTPUT:-
3. Write a C program to print the character string entered
by the user
CODE:-
#include<stdio.h>
int main()
char x[10];
printf("Enter character=");
scanf("%s",&x);
printf("The Character you entered is = %s",x);
}
OUTPUT:_
4. WRITE A PROGRAM TO PRINT A CHARACTER ENTER BY
PROGRAMER:-
CODE:-
#include<stdio.h>
int main()
char c[10]="Aastha";
printf("The Character you entered is %s",c);
}
OUTPUT:-
5.WRITE A PROGRAM TO INPUT COLOR NAME AND NUMBER
OF BALL PEN AND DISPLAY THEM :-
CODE:-
#include<stdio.h>
int main()
char col_nm[10];
int num_pen;
printf("Enter Pen Colour:- ");
scanf("%s",&col_nm); printf("Enter
Numbers of ball pen:- ");
scanf("%d",&num_pen);
printf("Your Pen colour is %s \n",col_nm);
printf("Your Numbers of ball pen is %d",num_pen);
OUTPUT:-
6. Write a C program to print Student Name, Student Roll
Number, Student City, Branch and Mobile Number entered by
the user.
CODE:-
#include<stdio.h>
int main()
char nm[20],roll[9],ct[20],branch[10],mob[10];
printf("Enter Your Name:- ");
scanf("%s",&nm);
printf("Enter Your Roll No.:- ");
scanf("%s",&roll);
printf("Enter Your City:- ");
scanf("%s",&ct);
printf("Enter Your Branch:- ");
scanf("%s",&branch);
printf("Enter Your Mobile No.:- ");
scanf("%s",&mob);
printf("Your Name is %s \n",nm);
printf("Your Roll No. is %s \n",roll);
printf("Your City is %s \n",ct);
printf("Your Branch is %s \n",branch);
printf("Your Mobile No. is %s \n",mob);
}
OUTPUT:-
7. . Write a C program to input Product ID, Product Name, per
Unit Price and Quantity. Display total bill with all the details
after applying 18% GST in a bill.
CODE:-
#include <stdio.h>
int main()
{
int quantity;
char pnm[50],pid[5];
float price,total,gst,bill;
printf("Enter Product
ID:");
scanf("%s",pid);
fflush(stdin);
printf("Enter Product
Name: ");
scanf("%s",pnm);
printf("Enter Per Unit
Price: ");
scanf("%f",&price);
printf("Enter Quantity: ");
scanf("%d",&quantity);
total=price*quantity;
gst=0.18*total; bill=total+gst;
printf("=========== Bill Details =========\n");
printf("Product ID: %s\n",pid);
printf("Product Name: %s\n",pnm);
printf("Per Unit Price: %.2f\n",price);
printf("Quantity: %d\n",quantity);
printf("Total Amount: %.2f\n",total);
printf("GST (18%): %.2f\n",gst);
printf("Total Bill: %.2f\n",bill);
printf("==================================");
}
OUTPUT:-
8. Write a program to input details of a citizen and display
them:
Full Name:
Address:
City:
Pin Code:
District:
State:
Mobile Number:
Email Address:
Blood Group:
Age:
CODE:-
#include <stdio.h>
int main()
{
char fullname[60],address[100],city[20],pin[6],district[20];
char state[20],mobile[10],email[100],bloodgroup[3];
int age;
printf("Enter Full Name: ");
scanf("%s",fullname);
printf("Enter Address: ");
scanf("%s",address);
printf("Enter City: ");
scanf("%s",city);
printf("Enter Pin Code: ");
scanf("%s",pin);
printf("Enter District: ");
scanf("%s",district);
printf("Enter State: ");
scanf("%s",state);
printf("Enter Mobile Number: ");
scanf("%s",mobile);
printf("Enter Email Address: ");
scanf("%s",email);
printf("Enter Blood Group: ");
scanf("%s",bloodgroup);
printf("Enter Age: ");
scanf("%d",&age);
printf("\n===== Citizen Details =====\n");
printf("Full Name: %s\n",fullname);
printf("Address: %s\n",address);
printf("City: %s\n",city);
printf("Pin Code: %s\n",pin);
printf("District: %s\n",district);
printf("State: %s\n",state);
printf("Mobile Number: %s\n",mobile);
printf("Email Address: %s\n",email);
printf("Blood Group: %s\n",bloodgroup);
printf("Age: %d\n",age);
}
OUTPUT:-