C Answers

Questions answered by Experts: 1 680

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search

Write a program to evalute the series.

1+3+5+7+........+n


Requires to follow the program template provided and use stack to solve the problem.



Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.


An input string is valid if:


Open brackets must be closed by the same type of brackets.

Open brackets must be closed in the correct order.


Example 1:


Input: s = "()"

Output: true


Example 2:


Input: s = "()[]{}"

Output: true


Example 3:


Input: s = "(]"

Output: false


Example 4:


Input: s = "([)]"

Output: false


Example 5:


Input: s = "{[]}"

Output: true


Program Template


#include <stdio.h>

#include <stdlib.h>


// This is where the parentheses are stored in memory

char buffer[1024];

char stack_pop();

void stack_push(char ch);

int stack_size();



int main(){

FILE *fp;

  // The parentheses sequences is in the parentheses.txt file.

  fp=fopen("parentheses.txt","r");

  if(fp==NULL){

   printf("The input file does not exist.\n");

   exit(-1);

  }

  // Read the parenthese sequences into buffer array.

  fgets(buffer,1024,fp);

  //printf("%s",buffer);

}


// The pop operation in the stack. To be done.

char stack_pop(){

return ')';

}



// The push operation in the stack. To be done.

void stack_push(char ch){

}



// The number of elements in the stack. To be done.

int stack_size(){

return 0;

}




Write a program to take input for students (id, name, cgpa) until id is given zero, put those student info into a linked list or add those student info at the tail of linked list. After adding all those students, print all student info into a binary file. Create another program to read the entries again.


Write a function int solution(int A[], int that given an array A consisting of N integers, returns the sum of all integers which are multiples of 4


Given a compiler which allocates 4 Bytes of memory to an integer variable, then what is the range of numbers that can be stored in such variable? Explain your answer.



Write a C system program that creates a process chain of 32 processes having the following characteristics. 1. Each process prints two prime numbers that are generated randomly in the range of 1-1000. 2. Each parent must wait for its child process to terminate.

Your answer


int a=6,b=3;

printf("%d",(++a*b--));


Write C code for Atmega32 programming for the following scenario:

Divide the last two digits of your ID with 9 and find the remainder. (last two digits of my id is: 58)


If the remainder is even, then use a 7-segment Common Anode Display. If the remainder is odd, then use a 7-segment Common Cathode Display.


Now connect PORTC pin no. 0 to 6 with the display and display the last digit of your ID.


Write C code for Atmega32 programming for the following scenario:

Create a LED pattern with 8 LEDs which will represent the BCD value 0101 1000


Example:

The pattern will start to loop in the following order.

Loop:

{

First 0101 will be on and 1000 will be off for 2.5 seconds.

Next, 0101 will be off and 1000 will be on for 2.5 seconds.

Next, all 0101 and 1000 will be on for 2.5 seconds.

Next, all will be off for 2.5 seconds.

}


Write a program in C to insert a node in 2nd place and print all nodes data
LATEST TUTORIALS
APPROVED BY CLIENTS