answersLogoWhite

0

📱

C Programming

Questions related to the C Computer Programming Language. This ranges all the way from K&R to the most recent ANSI incarnations. C has become one of the most popular languages today, and has been used to write all sorts of things for nearly all of the modern operating systems and applications. It it a good compromise between speed, power, and complexity.

9,649 Questions

What is data segment memory and code segment memory?

Code Segment, in which all the application code is stored
Data Segment
, that holds the global data

Is there any graphics program in c?

Search for BGIDEMO.C in your TurboC. There are thousands. Many Unix/Linux graphics programs are written mainly in C or C++, including X itself.

Print a c program to find greatest of 4 numbers?

#include<stdio.h>

#include<conio.h>

void main()

{

int a[4],max,i;

clrscr();

printf("Enter the four numbers:\n");

for(i=0;i<4;i++)

scanf("%d",a[i]);

max=a[o];

for(i=1;i<4;i++)

{

if(a[i]>max)

{

max=a[i];

}

}

printf("The Greatest number is %d",max);

getch();

}

Write a c program to represent graph as an adjacency multilist form?

#include #include #include #define max 10 struct node { int vertex; struct node *next; }; typedef struct node* nodeptr; typedef struct queue { int front,rear; int arr[max]; }; typedef struct stack { int top; int arr[max]; }; nodeptr getnode() { nodeptr p;p=(nodeptr)malloc(sizeof(struct node)); p->next=NULL; return p; } int empty(struct stack *s) {if(s->top==-1) { return 1; }else return 0; } void push(struct stack *s,int x) {if(s->top==max-1)printf("\n Queue Overflow"); else {s->top++;s->arr[s->top]=x; } } int pop(struct stack *s) { int x;if(empty(s)) printf("\n Queue Overflow..!"); else {x=s->arr[s->top];s->top--; } return x; } int qempty(struct queue *q) {if(q->front > q->rear)return 1; else return 0; } void insertq(struct queue *q,int x) {if(q->rear==max-1)printf("\n Queue Overflow..1"); else {q->rear++;q->arr[q->rear]=x; } } int removeq(struct queue *q) { int x;if(qempty(q)) printf("\n Queue Overflow..!"); else {x=q->arr[q->front];q->front++; } return x; } void init(nodeptr head[],int n) { int v;for(v=1;v<=n;v++)head[v]=NULL; } void initialise_visit(int visited[],int n) { int i;for(i=1;i<=n;i++)visited[i]=0; } void create(nodeptr head[]) { nodeptr adj; char ch='y'; int i,v1,v2,v,c; nodeptr new1,p; printf("\n <0>Directed");printf("\n <1>UnDirected"); printf("\n Enter Your Choice:\t");scanf("%d",&c); do {printf("\n Enter The Edge Between Two Vertices:\t");scanf("%d%d",&v1,&v2);new1=getnode();new1->vertex=v2;p=head[v1]; if(p==NULL)head[v1]=new1; else {while(p->next!=NULL)p=p->next;p->next=new1; }if(c==1) {new1=getnode();new1->vertex=v1;p=head[v2]; if(p==NULL)head[v2]=new1; else {while(p->next!=NULL)p=p->next;p->next=new1; } } printf("\n Do You Want To Add More Edges In Graph(y/n):\t");ch=getche(); }while(ch=='y'ch=='Y'); } void display(nodeptr head[],int n) { int v;nodeptr adj; printf("\n Adjancency List Is:\n");for(v=1;v<=n;v++) {printf("\n Head[%d]->",v);adj=head[v]; while(adj!=NULL) { printf("%d ",adj->vertex);adj=adj->next; } printf("\n"); } } void DFSR(nodeptr head[],int start,int visited[]) { nodeptr adj;visited[start]=1; printf("\t %d",start); adj=head[start];while(adj!=NULL) {if(visited[adj->vertex]==0) {DFSR(head,adj->vertex,visited); } adj=adj->next; } } void DFSN(nodeptr head[],int start,int visited[]) { nodeptr adj; struct stack s; int v; s.top=-1;push(&s,99);visited[start]=1; printf("\n %d",start); push(&s,start);do { adj=head[start];while(adj!=NULL) {if(visited[adj->vertex]==0) {visited[adj->vertex]=1;printf("\t%d",adj->vertex);push(&s,adj->vertex);start=adj->vertex; break; } else adj=adj->next; }if(adj==NULL) {start=pop(&s); } }while(!empty(&s)); } void BFS(nodeptr head[],int start,int visited[]) { nodeptr adj; struct queue q; int v;q.front=0; q.rear=-1;visited[start]=1; printf("\n %d",start);insertq(&q,start);while(!qempty(&q)) {v=removeq(&q);adj=head[v]; while(adj!=NULL) { if(visited[adj->vertex]==0) { visited[adj->vertex]=1;printf("\t %d",adj->vertex); }adj=adj->next; } } } void main() {char c='y'; int ch,start,n,visited[10]; nodeptr head[10]; clrscr(); do {clrscr(); printf("\n========Graph========");printf("\n 1. Create"); printf("\n 2. Display Adjancency List"); printf("\n 3. Depth First Search(Rec)"); printf("\n 4. Depth First Search(Non-Rec)"); printf("\n 5. Breadth First Search"); printf("\n 6. Exit");printf("\n====================="); printf("\n Enter Your Choice:\t");scanf("%d",&ch); switch(ch) { case 1: printf("\n Enter The No. of Vertices In Graph:\t"); scanf("%d",&n);init(head,n); create(head);break; case 2: display(head,n);break; case 3: printf("\n Enter The Vertex From Which You Want To Start Traversal");scanf("%d",&start);initialise_visit(visited,n); printf("\n Recursive Depth First Search Is\n");DFSR(head,start,visited); break;case 4: printf("\n Enter The Vertex From Which You Want To Start Traversal");scanf("%d",&start);initialise_visit(visited,n); printf("\n Non-Recursive Depth First Search Is\n");DFSN(head,start,visited); break;case 5: printf("\n Enter The Vertex From Which You Want To Start Traversal");scanf("%d",&start);initialise_visit(visited,n);BFS(head,start,visited); break;case 6: break; } printf("\n Do You Want To Continue(y/n):\t"); c=getche(); }while(c=='Y'c=='y'); getch(); }

If else else sample programs java?

if (i==2)

if (j==2) System.out.println ("i==2 and j==2");

else System.out.println ("i==2 and j<>2");

else System.out.println ("i<>2");

What operation is supported in constant time by the doubly linked list but not by the singly linked list?

examples:

- delete this node (identified by a pointer)

- insert a new node before this node

- replace this node with another node

Why use stdlib header file?

Header files allow a C source file to use functions in other C files or library files. The linker ignores the fact that these functions are not defined in C source code, assuming that they'll be defined somewhere else.

"stdlib" offers prototypes for many functions that deal with string conversion, pseudo-random number generation, dynamic memory management, program environment, integer math and other functions not available within the C standard.

See the related link below for a list of function prototypes offered by stdlib.h.

What statement defines a function?

A function is a relation that assigns exactly one output for each input from a specified set, known as the domain. This means that for every element in the domain, there is a corresponding element in the codomain, ensuring that no input is mapped to more than one output. In mathematical terms, a function can be expressed as ( f: X \rightarrow Y ), where ( f ) is the function, ( X ) is the domain, and ( Y ) is the codomain.

What are the linked list utility in memory management?

A simple linked-list is an approach is to store the freelist of memory blocks, where each node of the linked list contains a pointer to a single free block in the memory pool.

What is implicit stack?

A stack created by the user or a programmer is an implicit stack

What is a Header parameter?

A header parameter is a key-value pair sent in the HTTP headers of a request or response, providing essential metadata about the request or the resource being transferred. Header parameters can convey information such as content type, authorization credentials, caching directives, and more. They are crucial for controlling how clients and servers communicate and interpret the data being exchanged. Examples include "Content-Type," "Authorization," and "User-Agent."

What are the different between stack and queue?

  • A stack is generally First In, Last Out, and a queue is First In First Out.
  • Item can be added or removed only at one end in stack and in a queue insertion at the rear and deletion from the front.
  • The basic operation of stack are 'push' and 'pop', on other hand of queue are 'enque' and 'dequeue'.

Why the index of an array be a positive number?

Since an array cannot contain a negative number of items, the size of an array must be at least 0. So if you ever tried to retrieve the element at a negative index in an array, it would automatically be understood to be out-of-bounds.

How do people get num?

they get really cold and they can't feel a thing!