0% found this document useful (0 votes)
5 views2 pages

Assignments Set 1 & 2

The document is an assignment from Manipal University Jaipur by Mohammed Rihan, detailing the use of the printf function in C programming, particularly focusing on format specifiers and their corresponding data types. It includes examples of how to use various format specifiers such as %d, %u, %f, and others in printf statements. Additionally, it discusses decision control statements in C, including if, if-else, else-if ladder, and switch statements with a sample code demonstrating the if statement.

Uploaded by

md.rihan630015
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)
5 views2 pages

Assignments Set 1 & 2

The document is an assignment from Manipal University Jaipur by Mohammed Rihan, detailing the use of the printf function in C programming, particularly focusing on format specifiers and their corresponding data types. It includes examples of how to use various format specifiers such as %d, %u, %f, and others in printf statements. Additionally, it discusses decision control statements in C, including if, if-else, else-if ladder, and switch statements with a sample code demonstrating the if statement.

Uploaded by

md.rihan630015
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/ 2

MANIPAL UNIVERSITY JAIPUR

ASSIGNMENT
NAME-MOHAMMED RIHAN
ROLL NUMBER-2414500178
PROGRAM-BACHELOR OF COMPUTER APPLICATION
SEMESTER-1ST SEMESTER
SESSION-OCT 2024
COURSE CODE & NAME-DCA1107
---------------------------------------------------------------------------------------------------------------
. SET-1
_________________________________________________________________________
Answer.no.1: In c, the printf function is used to output data to the standard output (usually
the console).Format specifiers play a ccrucial role in this function, as they define how the
following arguments should be formatted and displayed.Each format specifier corresponds to
a specific data type – Role of format specifiers-Format specifiers tell printf how to interpret
the data passes to it,specifying things like (1)The type of data (e.g, integer,floating-
point,string) (2)The width of the output (3)Precision for floating_numbers (4)Different
formatting options (e.g.padding,alignment)-Common Format Specifiers:Here are some
common format specifiers along with their corresponding data types:
Format specifier Data type Description
%d int signed decimal integer
%u unsigned int unsigned decimal integer
%f float for double floating point number
%c char * string of haracters (character array)
%x unsigned int unsigned hexadecimal integer(lowercase)
%o unsigned int unsigned octal integer
%p void * pointer address
%% none percent sign(used to print a literal %)
Examples: here are some examples demonstrating the use of different format specifiers in
printf: c- int main () { int integer =42; unsigned int u_integer=42; float float_num =3.14159;
char character =’A’; char string[ ]= “Hello,wor1d! void *ptr =&integer; // using format
specifiers :(1) printf(“signed integer:%d\n”, integer); // output;signed integer: 42 (2)printf
(“unsigned integer; %u\n”, u_integer); // output: unsigned integer:42 (3) printf(“floating
point: % 2f\nn”, float_num);// output:floating point :3.14 (4) printf (“character:%c\
n”,character);//output :character:A (5) Printf (“string :%s\n”,string); // output:string:
hello,world! (6)printf(“hexadecimal:%x\n”,u_integer);//output:hexadecimal:2a
__________________________________________________________________________
Answer no.2: In c programming,decision control statements allow you to execute certain
blocks of code based on specific conditions. The primary decision control statements are: 1-if
statement 2.if-else statement 3.else-if ladder 4.switch statement (1)if statement :The if
statement evaluates a condition and executes a block of code if the conditions is true.
Example: int main() {int number=10; if (number>0){printf(“The number is positive.\
n”);}return 0;}

You might also like