100% de satisfacción garantizada Inmediatamente disponible después del pago Tanto en línea como en PDF No estas atado a nada 4,6 TrustPilot
logo-home
Examen

C Programming Questions and answers

Puntuación
-
Vendido
-
Páginas
61
Grado
A+
Subido en
12-09-2024
Escrito en
2023/2024

This document offers a collection of C programming interview questions, covering fundamental and advanced topics. It provides clear answers with explanations on concepts like arrays, pointers, recursion, and memory management, while also addressing practical coding challenges such as Fibonacci series, prime numbers, and factorials. The document serves as an excellent resource for those preparing for C programming interviews, offering both theoretical knowledge and practical coding examples to help reinforce key concepts and boost problem-solving skills.

Mostrar más Leer menos
Institución
Programming
Grado
Programming











Ups! No podemos cargar tu documento ahora. Inténtalo de nuevo o contacta con soporte.

Escuela, estudio y materia

Institución
Programming
Grado
Programming

Información del documento

Subido en
12 de septiembre de 2024
Número de páginas
61
Escrito en
2023/2024
Tipo
Examen
Contiene
Preguntas y respuestas

Temas

Vista previa del contenido

C Programming Interview Questions

1. What's the value of the expression 5["abxdef"]?

The answer is 'f'.

Explanation: The string mentioned "abxdef" is an array, and the expression
is equal to "abxdef"[5]. Why is the inside-out expression
equivalent? Because a[b] is equivalent to *(a + b) which is equivalent to *(b
+ a) which is equivalent to b[a].

2. What is a built-in function in C?

The most commonly used built-in functions in C are sacnf(), printf(), strcpy,
strlwr, strcmp, strlen, strcat, and many more.

Built-function is also known as library functions that are provided by the
system to make the life of a developer easy by assisting them to do certain
commonly used predefined tasks. For example, if you need to print output or
your program into the terminal, we use printf() in C.

3. In C, What is the #line used for?

In C, #line is used as a preprocessor to re-set the line number in the code,
which takes a parameter as line number. Here is an example for the same.

#include <stdio.h> /
*line 1*/

int main(){ /
*line 3*/

printf("Nello world\n"); /*line 5*
/
//print current line /*line 6*
/
printf("Line: %d\n",_LINE_); /*line 7*/
//reset the line number by 36 /*line 8*/
#line 36 /*reseting*/

, //print current line /*line 36
*/
printf("Line: %d\n",_LINE_); /*line 37*/
printf("Bye bye!!!\n"); /*line 39
*/

return 0; /
*line 41*/
}




4. How can a string be converted to a number?

The function takes the string as an input that needs to be converted to an
integer.

int atoi(const char *string)

Return Value:

 On successful conversion, it returns the desired integer value
 If the string starts with alpha-numeric char or only contains alpha-num char,
0 is returned.
 In case string starts with numeric character but is followed by alpha-num
char, the string is converted to integer till the first occurrence of
alphanumeric char.

, Converting String to
Number

5. How can a number be converted to a string?

The function takes a pointer to an array of char elements that need to be
converted, and a format string needs to be written in a buffer as a string

int sprintf(char *str, const char *format, ...)
#include<stdio.h>
#include <math.h>
int main()
{
char str[80];

sprintf(str, "The value of PI = %f", M_PI);
puts(str);

return 0;
}

Below is the output after running the above code:

Output: Value of Pi = 3.141593

6. Why doesn’t C support function overloading?

, After you compile the C source, the symbol names need to be intact in the
object code. If we introduce function overloading in our source, we should
also provide name mangling as a preventive measure to avoid function name
clashes. Also, as C is not a strictly typed language many things(ex: data types)
are convertible to each other in C. Therefore, the complexity of overload
resolution can introduce confusion in a language such as C.

When you compile a C source, symbol names will remain intact. If you
introduce function overloading, you should provide a name mangling
technique to prevent name clashes. Consequently, like C++, you'll have
machine-generated symbol names in the compiled binary.

Additionally, C does not feature strict typing. Many things are implicitly
convertible to each other in C. The complexity of overload resolution rules
could introduce confusion in such kind of language

7. What is the difference between global int and static int declaration?

The difference between this is in scope. A truly global variable has a global
scope and is visible everywhere in your program.

#include <stdio.h>

int my_global_var = 0;

int
main(void)

{
printf("%d\n", my_global_var);
return 0;
}

global_temp is a global variable that is visible to everything in your program,
although to make it visible in other modules, you'd need an ”extern int
global_temp; ” in other source files if you have a multi-file project.

A static variable has a local scope but its variables are not allocated in the
stack segment of the memory. It can have less than global scope, although -
like global variables - it resides in the .bss segment of your compiled binary.
$11.49
Accede al documento completo:

100% de satisfacción garantizada
Inmediatamente disponible después del pago
Tanto en línea como en PDF
No estas atado a nada

Conoce al vendedor

Seller avatar
Los indicadores de reputación están sujetos a la cantidad de artículos vendidos por una tarifa y las reseñas que ha recibido por esos documentos. Hay tres niveles: Bronce, Plata y Oro. Cuanto mayor reputación, más podrás confiar en la calidad del trabajo del vendedor.
ScholarSync Teachme2-tutor
Seguir Necesitas iniciar sesión para seguir a otros usuarios o asignaturas
Vendido
181
Miembro desde
1 año
Número de seguidores
5
Documentos
2227
Última venta
2 horas hace
ScholarSync

Welcome To my Store# My Goal is to help you achieve your desired grades by providing credible study materials I'm happy to help you with quality documents On this page you will find quality study guides,Exams assignments, Research papers and Test Banks all verified correct . you'll find past and recent revised and verified study materials . Stay here and You'll find everything you need to pass !!! . I always ensure my documents are of high standards I am always available to assist 24/7 and answer any queries you may have . ........Be assured to get good grades and always leave a review after a purchase......... .........REFER A FRIEND............. SUCCESS!!!!

Lee mas Leer menos
4.6

10 reseñas

5
9
4
0
3
0
2
0
1
1

Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes