• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 4 out of 32 pages
Exam (elaborations)

C-programming questions and answers

Document preview thumbnail
Preview 4 out of 32 pages

The document contains a series of programming-related questions and answers, primarily focused on the C programming language. It covers fundamental concepts such as swapping variables, tokens, call by value, time complexity, and characteristics of C. It also explains programming structures like flowcharts, data types, and storage classes. Additionally, the document discusses functions like `getch()` and `getchar()`, and control statements like break and continue. Each topic is supplemented with explanations, examples, and sample code to demonstrate key concepts.

Content preview

QUESTIONS WITH ANSWERS
1. what do you mean by swapping?
Ans- Swapping two number in C
programming language means exchanging
the values of two variables. Suppose you
have two variable var1 & var2. Value of
var1 is 20 & value of var2 is 40. So, after
swapping the value of var1 will become 40
& value of var 2 will become 20.
#include<stdio.h>
int main() {
double first, second, temp;
printf("Enter first number: ");
scanf("%lf", &first);
printf("Enter second number: ");
scanf("%lf", &second);


// value of first is assigned to temp
temp = first;

, // value of second is assigned to first
first = second;


// value of temp (initial value of first) is
assigned to second
second = temp;


// %.2lf displays number up to 2 decimal
points
printf("\nAfter swapping, first number =
%.2lf\n", first);
printf("After swapping, second number =
%.2lf", second);
return 0;
}
Two types of swapping basically
a. call by value
b. call by reference

,2.what is token?
Ans- Tokens in C is the most important
element to be used in creating a program
in C. We can define the token as the
smallest individual element in C. For
`example, we cannot create a sentence
without using words; similarly, we cannot
create a program in C without using tokens
in C. Therefore, we can say that tokens in C
is the building block or the basic
component for creating a program in C
language.




o Keywords in C
o Identifiers in C
o Strings in C

, o Operators in C
o Constant in C
o Special Characters in C


3.what do you mean by call by value?
Ans- The call by value method of passing
arguments to a function copies the actual
value of an argument into the formal
parameter of the function. In this case,
changes made to the parameter inside the
function have no effect on the argument. By
default, C programming uses call by value
to pass arguments.
/* function definition to swap the values */
void swap(int x, int y) {


int temp;


temp = x; /* save the value of x */
x = y; /* put y into x */

Document information

Uploaded on
September 12, 2024
Number of pages
32
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers
$10.99

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
ScholarSync
4.3
(19)
Sold
237
Followers
5
Items
3042
Last sold
1 month ago



Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions